<template>
	<div class="box8">
		<div class="topb">
			<el-input placeholder="请输入商品名称" class="inpsa" v-model="inpgoodsname" @keyup.enter.native="seachall"></el-input>
			<el-date-picker placeholder="请输入销售时间" v-model="inpdate" style="width: 170px; margin-right: 10px;" @change="seachall">
			</el-date-picker>
			<el-input placeholder="请输入用户名" class="inpsa" v-model="inpusername" @keyup.enter.native="seachall"></el-input>
			<el-button type="primary" icon="el-icon-search" class="search" @click="seachall">搜索</el-button>
		</div>
		<div class="banner">
			<el-table :data="ticket" style="width: 100%">
				<el-table-column prop="outletName" label="门店名">
				</el-table-column>
				<el-table-column prop="wareName" label="商品名称">
				</el-table-column>
				<el-table-column prop="sellTime" label="销售时间">
				</el-table-column>
				<el-table-column prop="userName" label="用户信息">
					<template slot-scope="scope">
						<a class="a_back" href="#" @click="handleClickTableRow(scope.row)">{{ scope.row.userName }}</a>
					</template>
				</el-table-column>
				<el-table-column prop="vipPrice" label="会员价格">
				</el-table-column>
				<el-table-column prop="price" label="实际价格">
				</el-table-column>
				<el-table-column prop="sellDescr" label="备注">
				</el-table-column>
			</el-table>
			<!--分页-->
			<el-row>
				<el-col style="text-align:right">
					<el-pagination layout="prev, pager, next" :total="total" :page-size="pagesize"
						:current-page="currentpage" @current-change='changePage'></el-pagination>
				</el-col>
			</el-row>
		</div>
	</div>
</template>
<script>
export default {
	data() {
		return {
			baseUrl: require("../assets/baseUrl.js").baseUrl,
			total: 0, //总数据条数
			currentpage: 1, //当前所在页默认是第一页
			pagesize: 5, //每页显示多少行数据 默认设置为10
			ticket: [], //这里是从后端获取的所有数据
			inpdate:"",
			inpgoodsname:"",
			inpusername:"",
			adminId:0,
			time:''
		}
	},
	methods: {
		// //跳到详情
		 handleClickTableRow(row) {
		/* 	console.log(row) */
		 	this.$router.push('/staticsproject/statisticsdetails?userId=' + row.userId)
		},


		//日期格式
		changedate() {
	
		},
		//分页
		changePage(page) {
			this.currentpage = page
			this.getseachall()
	
		},
		seachall(){
			this.currentpage=1
			this.getseachall()
		},
		//搜索
		getseachall(){
			this.adminId=Number(sessionStorage.getItem("adminId"))
			if(this.inpdate){
				var data=this.inpdate
			var y = data.getFullYear();
			var m=data.getMonth()+1
			m = m < 10 ? ('0' + m) : m;
			var d = data.getDate();
			d = d < 10 ? ('0' + d) : d;
			this.time = y + '-' + m + '-' + d;
			this.$http.post(this.baseUrl+"sells/getOutletSellInfo",{
				page: this.currentpage+"",
				size: this.pagesize+"",
				adminId:this.adminId,
				wareName:this.inpgoodsname,
				sellTime:this.time,
				userName:this.inpusername

			}).then(res=>{
				if(res.data.code==200){
					this.ticket = res.data.data.sells
					this.total = res.data.data.totalPages * this.pagesize
				}
			})
			}else{
				this.$http.post(this.baseUrl+"sells/getOutletSellInfo",{
				page: this.currentpage+"",
				size: this.pagesize+"",
				adminId:this.adminId,
				wareName:this.inpgoodsname,
				userName:this.inpusername

			}).then(res=>{
				if(res.data.code==200){
					/* console.log(res) */
					this.ticket = res.data.data.sells
					this.total = res.data.data.totalPages * this.pagesize
				}
			})
			}
			
			
		}
	},
	mounted() {
		
		this.getseachall()
	
	}
}
</script>
<style lang="less">
.box8 {
	display: flex;
	flex-direction: column;
	.a_back{
		color: #000;
	}
	.topb {
		width: 80vw;
		height: 65px;
		display: flex;
		line-height: 60px;
		margin-bottom: 15px;
		margin-left: 30px;
		position: relative;
	}

	.banner {
		float: left;
		display: flex;
		flex-direction: column;
		width: 80vw;
		margin-left: 30px;
	}

	.el-pagination {
		margin-top: 30px;
		text-align: center;
	}

	.el-input__prefix {
		font-size: 24px;
	}

	.inpsa {
		width: 140px;
		margin-right: 10px;
	}

	.heng {
		height: 65px;
		line-height: 60px;
		font-size: 20px;
		margin-left: 30px;
	}

	.cell {
		text-align: center;
		display: flex;
		justify-content: center;
	}


	.el-input--prefix .el-input__inner {
		width: 170px;
	}

	.search {
		width: 80px;
		height: 40px;
		margin-top: 10px;
		position: relative;
		padding: 0px 26px 0 5px;

		.el-icon-search {
			position: absolute;
			top: 12px;
			right: 7px;
			font-size: 17px;
		}

		.el-button--primary>span {
			position: absolute;
			left: 15px;
			top: 35%;
		}
	}

	.addto {
		width: 40px;
		height: 50px;
		display: flex;
		flex-wrap: wrap;
		position: absolute;
		right: 10px;
	}

	.el-icon-plus {
		width: 40px;
		height: 34px;
		font-size: 34px;
		text-align: center;
	}

	.addto>span {
		width: 40px;
		height: 20px;
		text-align: center;
		font-size: 12px;
		line-height: 20px;
	}
}
</style>